import  {userAPI} from '../../request/api'

export default({
  namespaced:true,
  state: {
	  userInfo:{
		  nickName:'请先登录',
		  coin:'--',
		  headImg:require('../../assets/img/userImg.f8bbec5e.png')
	  }
	  //初始化用户信息
  },
  getters: {
  },
  mutations: {
	  //更新用户信息
	  changeuserinfo(state,val){
		  state.userInfo=val.userInfo
	  },
	  Resinfo(state){
		  state.userInfo={
		  		  nickName:'请先登录',
		  		  coin:'--',
		  		  headImg:require('../../assets/img/userImg.f8bbec5e.png')
		  }
	  }
  },
  actions: {
	  //发请求
	  async changeUser(context){
		const userRes=await userAPI();
		console.log(userRes);
		  context.commit('changeuserinfo',userRes.data)
	  }
  },
  modules: {
  }
})
